﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TriviaFinal
{
	public struct QuestionStruct
	{
		public string quest;
		public string a0;
		public string a1;
		public string a2;
		public string a3;
		public int correctAnswer;
	}

	class Trivia
	{
		public int questionPlacement = 0;
		int[] questionNumbers = new int[100];
		List<QuestionStruct> questions = new List<QuestionStruct>();
		int x = 0;

		public void Trivia1()
		{
			Shuffle();
			//shuffling the index values
			TextReader tr = new StreamReader("Question.txt");

			string input = tr.ReadLine();
			while (input != null)
			{
				string[] question = input.Split('/');
				QuestionStruct qsp;
				qsp.quest = question[0];
				qsp.a0 = question[1];
				qsp.a1 = question[2];
				qsp.a2 = question[3];
				qsp.a3 = question[4];
				qsp.correctAnswer = int.Parse(question[5]);

				questions.Add(qsp);

				input = tr.ReadLine();
			}
			tr.Close();
		}
		public void Shuffle()
		{
			for (int index = 0; index < 100; index++)
			{
				questionNumbers[index] = index;
			}

			questionNumbers = shuffle(questionNumbers);
		}
		public static int[] shuffle(int[] arr)
		{
			Random rnd = new Random();

			for (int i = 0; i < arr.Length; i++)
			{
				int temp = arr[i];
				int rndVal = rnd.Next(arr.Length);
				arr[i] = arr[rndVal];
				arr[rndVal] = temp;
			}

			return arr;
		}

		public string[] GetTrivia()
		{

			QuestionStruct question = questions[questionNumbers[x++]];
			if (x >= questions.Count)
				x = 0;

			string[] response = { question.quest, question.a0, question.a1, question.a2, question.a3, question.correctAnswer.ToString() };

			return response;

		}
	//class Question
	//{
		//private string question;
		//private string answera;
		//private string answerb;
		//private string answerc;
		//private string answerd;

		//public Question(string q, string a, string b,string c,string d)
		//{
		  // question = q;
		   //answera = a;
			//answerb = b;
			//answerc = c;
			//answerd = d;
		//}

		//public string Questions
		//{
			//get { return question;}
			//set {question = value;}
		//}

		//public string Answera
		//{
			//get { return answera;}
			//set {answera = value;}
		//}
		
		//public string Answerb
		//{
			//get { return answerb;}
			//set {answerb = value;}
		//}
		
		//public string Answerc
		//{
			//get { return answerc;}
			//set {answerc = value;}
		//}

		//public string Answerd
		//{
			//get { return answerd;}
			//set {answerd = value;}
		//}
	}
}
